package ssm.xml.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import ssm.xml.pojo.Person;

import java.util.Arrays;
import java.util.Map;

@Controller
public class ParamController {

    @ResponseBody
    @RequestMapping(value = "get00", method = RequestMethod.GET)
    public String get00(String abc, String xyz) {
        System.out.println(abc + "\t" + xyz);
        return abc + "\t" + xyz;
    }

    @ResponseBody
    @RequestMapping(value = "get01", method = RequestMethod.GET)
    public String[] get01(String[] arr) {
        System.out.println(Arrays.toString(arr));
        return arr;
    }

    @ResponseBody
    @RequestMapping(value = "get02", method = RequestMethod.GET)
    public Map<String, Object> get02(@RequestParam Map<String, Object> map) {
        map.forEach((key, value) -> {
            System.out.println(key + "：" + value + ":" + value.getClass().getTypeName());
        });
        return map;
    }

    @ResponseBody
    @RequestMapping(value = "get03", method = RequestMethod.GET)
    public String get00(@RequestParam("abc") String zxc) {
        System.out.println(zxc);
        return zxc;
    }

    @ResponseBody
    @RequestMapping(value = "get04", method = RequestMethod.GET)
    public Person get04(Person person) {
        System.out.println(person);
        return person;
    }

    /**
     * =============================================================================================================
     */

    @ResponseBody
    @RequestMapping(value = "post00", method = RequestMethod.POST)
    public Person post00(Person person) {
        System.out.println(person);
        return person;
    }

    @ResponseBody
    @RequestMapping(value = "post01", method = RequestMethod.POST)
    public String post00(String abc, String xyz) {
        System.out.println(abc + "\t" + xyz);
        return abc + "\t" + xyz;
    }
}